]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
volume.js: make slider menu items activatable
authorRui Matos <tiagomatos@gmail.com>
Fri, 6 May 2011 16:34:19 +0000 (17:34 +0100)
committerRui Matos <tiagomatos@gmail.com>
Tue, 19 Jul 2011 23:25:11 +0000 (00:25 +0100)
Keeping the volume menu open after setting the desired volume isn't that
useful and forces a second click (or an Esc press) to dismiss it. Allow for
the sliders to be used with a single click-hold-move-release.

https://bugzilla.gnome.org/show_bug.cgi?id=649586

js/ui/popupMenu.js
js/ui/status/volume.js

index 9e256b58fe7defe44e6f6bda4d09638ee5a811cf..1291cbe76d7022424e724e76fe643661914b238a 100644 (file)
@@ -482,8 +482,8 @@ function PopupSliderMenuItem() {
 PopupSliderMenuItem.prototype = {
     __proto__: PopupBaseMenuItem.prototype,
 
-    _init: function(value) {
-        PopupBaseMenuItem.prototype._init.call(this, { activate: false });
+    _init: function(value, params) {
+        PopupBaseMenuItem.prototype._init.call(this, params ? params : { activate: false });
 
         this.actor.connect('key-press-event', Lang.bind(this, this._onKeyPressEvent));
 
index bd74cd9d5b279c22eb32a72acf3a37bbcf08f5f6..438a8727554c8ca548e599e7acd2b79a008da993 100644 (file)
@@ -41,7 +41,7 @@ Indicator.prototype = {
         this._outputVolumeId = 0;
         this._outputMutedId = 0;
         this._outputTitle = new PopupMenu.PopupMenuItem(_("Volume"), { reactive: false });
-        this._outputSlider = new PopupMenu.PopupSliderMenuItem(0);
+        this._outputSlider = new VolumeSliderMenuItem(0);
         this._outputSlider.connect('value-changed', Lang.bind(this, this._sliderChanged, '_output'));
         this._outputSlider.connect('drag-end', Lang.bind(this, this._notifyVolumeChange));
         this.menu.addMenuItem(this._outputTitle);
@@ -54,7 +54,7 @@ Indicator.prototype = {
         this._inputVolumeId = 0;
         this._inputMutedId = 0;
         this._inputTitle = new PopupMenu.PopupMenuItem(_("Microphone"), { reactive: false });
-        this._inputSlider = new PopupMenu.PopupSliderMenuItem(0);
+        this._inputSlider = new VolumeSliderMenuItem(0);
         this._inputSlider.connect('value-changed', Lang.bind(this, this._sliderChanged, '_input'));
         this._inputSlider.connect('drag-end', Lang.bind(this, this._notifyVolumeChange));
         this.menu.addMenuItem(this._inputTitle);
@@ -231,3 +231,30 @@ Indicator.prototype = {
             this.setIcon(this._volumeToIcon(this._output.volume));
     }
 };
+
+function VolumeSliderMenuItem() {
+    this._init.apply(this, arguments);
+}
+
+VolumeSliderMenuItem.prototype = {
+    __proto__: PopupMenu.PopupSliderMenuItem.prototype,
+
+    _init: function(value) {
+        PopupMenu.PopupSliderMenuItem.prototype._init.call(this, value, { activate: true });
+
+        this.actor.connect('motion-event', Lang.bind(this, this._onMotionEvent));
+    },
+
+    activate: function(event) {
+        this._motionEvent(this.actor, event);
+        this.emit('drag-end');
+        this.emit('activate', event);
+    },
+
+    _onMotionEvent: function(actor, event) {
+        let button_pressed = Shell.get_event_state(event) & Clutter.ModifierType.BUTTON1_MASK;
+        if (button_pressed && !this._dragging)
+            return this._motionEvent(actor, event);
+        return false;
+    }
+};